$this->rlUserModuleState = $exemptStates['user'] = $userState;
}
- $rlClient = new ResourceLoaderClientHtml( $context, $this->getTarget() );
+ $rlClient = new ResourceLoaderClientHtml( $context, [
+ 'target' => $this->getTarget(),
+ ] );
$rlClient->setConfig( $this->getJSVars() );
$rlClient->setModules( $this->getModules( /*filter*/ true ) );
$rlClient->setModuleStyles( $moduleStyles );
/** @var ResourceLoader */
private $resourceLoader;
- /** @var string|null */
- private $target;
+ /** @var array */
+ private $options;
/** @var array */
private $config = [];
/**
* @param ResourceLoaderContext $context
- * @param string|null $target [optional] Custom 'target' parameter for the startup module
+ * @param array $options [optional] Array of options
+ * - 'target': Custom parameter passed to StartupModule.
*/
- public function __construct( ResourceLoaderContext $context, $target = null ) {
+ public function __construct( ResourceLoaderContext $context, array $options = [] ) {
$this->context = $context;
$this->resourceLoader = $context->getResourceLoader();
- $this->target = $target;
+ $this->options = $options;
}
/**
}
// Async scripts. Once the startup is loaded, inline RLQ scripts will run.
- // Pass-through a custom target from OutputPage (T143066).
- $startupQuery = $this->target ? [ 'target' => $this->target ] : [];
+ // Pass-through a custom 'target' from OutputPage (T143066).
+ $startupQuery = isset( $this->options['target'] )
+ ? [ 'target' => (string)$this->options['target'] ]
+ : [];
$chunks[] = $this->getLoad(
'startup',
ResourceLoaderModule::TYPE_SCRIPTS,
public function testGetHeadHtmlWithTarget() {
$client = new ResourceLoaderClientHtml(
self::makeContext(),
- 'example'
+ [ 'target' => 'example' ]
);
// phpcs:disable Generic.Files.LineLength
public function testGetHeadHtmlWithNullTarget() {
$client = new ResourceLoaderClientHtml(
self::makeContext(),
- null
+ [ 'target' => null ]
);
// phpcs:disable Generic.Files.LineLength